home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_07
/
1007054a
< prev
next >
Wrap
Text File
|
1992-05-04
|
765b
|
33 lines
z#include <iostream.h>
class rational
{
public:
rational();
rational(long n, long d = 1);
rational &operator+=(rational r);
rational &operator-=(rational r);
rational &operator*=(rational r);
rational &operator/=(rational r);
rational operator+();
rational operator-();
double to_double();
friend ostream &operator<<(ostream &os, rational
r);
private:
long num, denom;
void simplify();
};
rational operator+(rational r1, rational r2);
rational operator-(rational r1, rational r2)
rational operator*(rational r1, rational r2)
rational operator/(rational r1, rational r2)
rational operator++(rational &r)
rational operator--(rational &r)
rational operator++(rational &r, int);
rational operator--(rational &r, int);